<?php

session_start();

if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {

    header("Location: login.php");
}
//
$_SESSION['DataType'] = "";
$_SESSION['Trace'] = "";
//
include 'i_functions.php';
include 'i_init_client.php';
//
//if ($_SERVER['REQUEST_METHOD'] == 'GET') {
//$ClientID = $_GET['ClientID'];
//print "ClientID=" . $ClientID . "<br>";
//$ID = htmlspecialchars($ClientID);

$db_conn = db_connect();
$db_handle = $db_conn['db_handle'];
$db_found = $db_conn['db_found'];

if ($db_found) {
    include 'i_head.php';
    $HTML = "<table id=\"Enq\" align=\"center\" cellspacing=\"0\"cellpadding=\"0\">";

    $csvFile = "ClaimsToAct.csv";
    $Columns = array();
    $Options = array();
    $Options['Name'] = "claims,client";
    $Options['TableOpts'] = "Align=\"center\"";
    $Options["Filter"] = "NextActDate <= NOW() AND client.ID = ClientID ";
    $Options["OrderBy"] = "NextActDate";
    $Options['Action'] = "./ClaimEnq.php?ClaimID=";
    //$Options['AllowNew'] = "Y";
    $Columns = array("claims.ID AS Claim", "ClientID AS Client", "CONCAT(client.Title, ' ', client.Surname) AS Name", "LenderName", "Status", "NextAction", "DateDiff(NOW(), Date(NextActDate)) AS Days", "Date(NextActDate) AS NextActDt");
    $Result = BuildDataArray("claims,client", $csvFile, $Columns, $Options);
    $HTML_F = Array2Table($xData, $Columns, $Options);

    print $HTML_F;
    include 'i_foot.html';
}
?>